package com.ck.shardinggo.controller.test;

import com.ck.shardinggo.model.User;
import com.ck.shardinggo.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Api(value = "/user",tags = "用户")
@Controller
@RequestMapping("/user")
@Slf4j
public class UserController {
	
	@Autowired
	private IUserService userService;

	@ApiOperation(value = "保存用户")
	@PostMapping("/save")
	@ResponseBody
	public String save(@ApiParam("user") User user) {
		userService.save(user);
		return "success";
	}

	@ApiOperation(value = "查询用户")
	@GetMapping("/get/{id}")
	@ResponseBody
	public User get(@ApiParam(name = "id") @PathVariable Long id) {
		User user =  userService.get(id);

		return user;
	}
	
	
	

}
